<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<div id="people">
<form id="addPeople" name="addPeople" onsubmit="return false" >
<table cellpadding="0" cellspacing="0">
    <tr>
    	<td><label for="number">登录号：</label></td>
    	<td style="text-align:left;">
    		<input name="number" id="number" style="min-width:300px;"/>
    	</td>
    </tr>
    <tr>
    	<td><label for="name">姓名：</label></td>
    	<td><input type="text" name="name" id="name" style="min-width:300px;" /></td>
    </tr>
    <tr>
    	<td><label for="sex">性别：</label></td>
    	<td>
	   		<select  name="sex" id="sex" style="min-width:300px;">
	      			<option value="boy">男</option>
	      			<option value="girl">女</option>
	   		</select>
    	</td>
    </tr>
    <tr>
    	<td><label for="login-id">登录身份：</label></td>
    	<td style="text-align:left;">
    		<select  name="login-id"  id="login-id"  style="min-width:300px;">
       			<option value="teacher">教师</option>
       			<option value="student">学员</option>
    		</select>
    	</td>
    </tr>
     <tr style=" visibility:hidden;" id="guide">
     	<td><label for="header">指导老师：</label></td>
     	<td style="text-align:left;">
     		<input name="header" id="header" style="min-width:300px;" />
     	</td>
     </tr>  <!--返回json数据-->
     <tr style=" visibility:hidden;" id="themajor">
    	<td><label for="major">专业：</label></td>
    	<td><input type="text" name="major" id="major" /></td>
    </tr>
     <tr style=" visibility:hidden;" id="none">
     	<td><label for="type" style="min-width:300px;">类型：</label></td>
     	<td style="text-align:left;"> 
     		<select  name="type" id="type"  style="min-width:300px;">
       			<option value="front">前台</option>
       			<option value="back">后台</option>
       			<option value="ps">美工</option>
    		</select>
    	</td>
   	</tr> 
    <tr>
    	<td colspan="2" align="center">
    		<input type="submit"  id="submit-addPeople" name="submit-addPeople" value="提交"  style="margin-top:10px;" />
   		</td>
	</tr>
</table>
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){

$("#login-id option:gt(0)").click(function(){
	var id=$('#login-id').val();
	$('#none').css('visibility',"visible");
	$('#guide').css('visibility',"visible");
	$('#themajor').css('visibility',"visible");
	})
	
$("#login-id option:eq(0)").click(function(){
	var id=$('#login-id').val();
	$('#none').css('visibility',"hidden");
	$('#guide').css('visibility',"hidden");
	$('#themajor').css('visibility',"hidden");
	})

$("#header").combobox({
	multiple:false,
	url:'GetTeacherServlet',/*返回指导老师json数据格式的链接*/
	valueField:"tno",
	textField:"tname",  //记得要对应，老师的
	editable:false,
	required:true, 
    //missingMessage:"此项为必填项"
})

$("#submit-addPeople").click(function(){
	var number=$("#number").val();
	var header=$("#header").combobox('getValue');
	var type=$('#type').val();
	if(number){
		$.ajax({
		url:'AddPeopleServlet',                         /*！！！！！后台注意更新处理页面的链接*/
		dataType:'text',
		data:$('#addPeople').serialize(),
		success:function(msg){
			//alert(msg);
			if(msg=='ok'){
						alert("添加成功");                /*处理函数，根据后台需要*/
						$('#dd').dialog('close');
			           var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'people/headman/people.jsp'
									 }
									}
									);  /*更新面板*/
			 
									
			 } else{
			 	alert("添加失败");
		 	}
	    }
	   })
   } else{
		alert('请补充完整信息');
		return false;
	}

})

})


</script>
</body>

</html>